package com.juzipi.demo.config;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

public class CustomerBusinessExceptionHandler {
    /*
    自定义业务处理异常类
     */

    @ResponseBody
    @ExceptionHandler(BusinessException.class)
    public Map<String,Object> businessExceptionHandler(BusinessException businessException){
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("code",businessException.getCode());
        hashMap.put("message",businessException.getMessage());
        return hashMap;

    }
}
